package com.yohann.designPattern.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 学校
 * </p>
 *
 * @author Yohann
 * @since 2021/2/7 16:33
 */
public class University extends OrganizationComponent {
    private List<OrganizationComponent> components = new ArrayList<>();

    public University(String name, String description) {
        super(name, description);
    }

    @Override
    protected void add(OrganizationComponent component) {
        components.add(component);
    }

    @Override
    protected void remove(OrganizationComponent component) {
        components.remove(component);
    }

    @Override
    protected void print() {
        System.out.println("<====== " + getName() + " ======>");
        System.out.println();
        for (OrganizationComponent component : components) {
            component.print();
        }
        System.out.println();
    }
}